package com.lagou.jdbc01;

import java.sql.*;

public class JDBCDemo01 {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.jdbc.Driver");
        Connection connection = DriverManager.getConnection("jdbc:mysql://192.168.2.145:3306/lagou?characterEncoding=UTF-8", "root", "1234@qwer");
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery("select * from jdbc_user");
        while (resultSet.next()) {
            int id = resultSet.getInt("id");
            String username = resultSet.getString("username");
            String password = resultSet.getString("password");
            Date birthday = resultSet.getDate("birthday");
            System.out.println("id=" + id + ",username=" + username + ",password=" + password + ",birthday=" + birthday);
        }
        statement.close();
        connection.close();
    }
}
